/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package main;

import dialog.AddBlockWindowDialog;
import dialog.CreateAcountDialog;
import dialog.ShowHistoryDialog;
import dto.ActiveEmail;
import dto.Application;
import dto.ApplicationAccessed;
import dto.BlockCondition;
import java.awt.AWTException;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.Toolkit;
import java.awt.event.MouseEvent;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.awt.image.BufferedImage;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import java.util.Timer;
import java.util.TimerTask;
import javax.imageio.ImageIO;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JFileChooser;
import javax.swing.JTable;
import javax.swing.border.TitledBorder;
import javax.swing.filechooser.FileNameExtensionFilter;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;
import jni.DDEClientUrlBrowser;
import util.DateUtil;
import util.ModelTable;
import util.ReadWriteFile;
import util.StringUtil;
import util.TableUtil;
import xml.XmlFile;
import xml.XmlFile2;
import xml.XmlFile3;
import xml.XmlFile4;
import xml.XmlFile5;

/**
 *
 * @author phat10130059
 */
public class Demo extends javax.swing.JFrame implements WindowListener {

    /**
     * Creates new form Demo
     */
    private ModelTable dmodel1;
    private ModelTable dmodel2;
    private ModelTable dmodel3;
    private ModelTable dmodel4;
    private TableRowSorter<ModelTable> sorter;
//    public static boolean running = false;
    public String filePath = null;
    Toolkit toolkit;
    Timer timer;
    public boolean isRunning = false;
    public List<Application> listApp;
    public String user;
    private List<ApplicationAccessed> list3;
    private List<ApplicationAccessed> list4;
    private String osArchitecture;
    private Login login;
    private Properties prop = new Properties();
    private InputStream input = null;
    public boolean langPo;
    //===========================================
    private String BtCreatePass;
    private String CbStartWithWindow;
    private String BorderTextTab1;
    private String BtAddApp;
    private String BtEditApp;
    private String BtRemoveApp;
    private String HeaderTab1;
    private String Window;
    private String User;
    private String Start;
    private String End;
    private String CbBlockWeb;
    private String BorderTextTab2;
    private String BtAddSite;
    private String BtEditWeb;
    private String BtRemoveWeb;
    private String HeaderTab2;
    private String Web;
    private String BorderTextTab3;
    private String BtViewHistory;
    private String JLabel31;
    private String BtRemoveBlock;
    private String HeaderTab3;
    private String Date;
    private String Time;
    private String BorderTextTab4;
    private String HeaderTab4;
    public String BorderTextAddBlockWindow;
    public String LbUserWindow;
    public String LbWindowIsRunning;
    public String LbKeyword;
    public String JCheckBox1;
    public String LbTimeFrom;
    public String LbTimeEnd;
    public String BtCancel;
    public String LbInfoTab1;
    public String TitleTextTab1CreateAcount;
    public String BorderTab1CreateAcount;
    public String LbReEmail;
    public String LbCode;
    public String LbInfoTab2;
    public String TitleTextTab2CreateAcount;
    public String BorderTab2CreateAcount;
    public String JLabel5Account;
    public String JLabel6Account;
    public String JLabel7Account;
    public String BtSendEmail1;
    public String BtSendEmail2;
    public String BtSendEmail3;
    public String TitleCreateAccount;
    public String TitleAddBlock;
    public String TitleShowHistory;
    public String TitleEditBlock;

    public Demo(Login login) {




        String osName = System.getProperty("os.name");
        osArchitecture = System.getProperty("os.arch");
//        String javaVersion = System.getProperty("java.version");
//        
        System.out.println("OS Name : " + osName);
        System.out.println(osArchitecture);

        if (osName.toLowerCase().startsWith("windows")) {
            // we change the temp directory because sometimes Windows is stupid and doesn't want to load jna.dll from the temp directory
            File tempDir = new File(System.getenv("USERPROFILE") + "\\AppData\\Local\\MyCompany\\temp");
            System.out.println("Using temp dir: " + tempDir.getPath());
            tempDir.mkdirs();
            System.setProperty("java.io.tmpdir", tempDir.getPath());

            filePath = tempDir.getPath();
        }


        //check language
        String rLang = ReadWriteFile.read(filePath + File.separator + "lang.phat");
        if (rLang.equals("po")) {
            langPo = true;
            initLanguage(filePath + File.separator + "lange.properties");
        } else if (rLang.equals("en")) {
            langPo = false;
            initLanguage(filePath + File.separator + "lange_en.properties");
        }



        //create all table
        creatTable1();
        creatTable2();
        creatTable3();
        creatTable4();

        initComponents();

        initTable1();
        initTable2();
        initTable3();
        initTable4();

        initCheckBoxBlockWeb();
        initCheckBoxStartWithWindow();

        user = System.getProperty("user.name").trim().toLowerCase();
        listApp = XmlFile.readFileXml(filePath + File.separator + "file.xml");

        toolkit = Toolkit.getDefaultToolkit();
        timer = new Timer();
        timer.schedule(new scheduleDailyTask1(), 1000, 4000);

        isRunning = true;

        this.setResizable(false);

        this.setIconImage(new ImageIcon(getClass().getResource("/img/icon.png")).getImage());

        setLocationRelativeTo(null);


        initTabPanel();

        initEmail();

        this.setLocationRelativeTo(null);

        this.addWindowListener(this);

        this.login = login;





    }

    private void initLanguage(String file) {
        try {
            input = new FileInputStream(file);
            Reader reader = new InputStreamReader(input, "UTF-8");

            // load a properties file
            prop.load(reader);


            BtCreatePass = prop.getProperty("BtCreatePass");
            TitleShowHistory = prop.getProperty("TitleShowHistory");
            //tab1
            CbStartWithWindow = prop.getProperty("CbStartWithWindow");
            BorderTextTab1 = prop.getProperty("BorderTextTab1");
            BtAddApp = prop.getProperty("BtAddApp");
            BtEditApp = prop.getProperty("BtEditApp");
            BtRemoveApp = prop.getProperty("BtRemoveApp");
            HeaderTab1 = prop.getProperty("HeaderTab1");
            Window = prop.getProperty("Window");
            User = prop.getProperty("User");
            Start = prop.getProperty("Start");
            End = prop.getProperty("End");
            //tab2
            CbBlockWeb = prop.getProperty("CbBlockWeb");
            BorderTextTab2 = prop.getProperty("BorderTextTab2");
            BtAddSite = prop.getProperty("BtAddSite");
            BtEditWeb = prop.getProperty("BtEditWeb");
            BtRemoveWeb = prop.getProperty("BtRemoveWeb");
            HeaderTab2 = prop.getProperty("HeaderTab2");
            Web = prop.getProperty("Web");
            //tab3
            BorderTextTab3 = prop.getProperty("BorderTextTab3");
            BtViewHistory = prop.getProperty("BtViewHistory");
            JLabel31 = prop.getProperty("JLabel31");
            BtRemoveBlock = prop.getProperty("BtRemoveBlock");
            HeaderTab3 = prop.getProperty("HeaderTab3");
            Date = prop.getProperty("Date");
            Time = prop.getProperty("Time");
            //tab4
            BorderTextTab4 = prop.getProperty("BorderTextTab4");
            HeaderTab4 = prop.getProperty("HeaderTab4");
            //AddBlockWindow
            TitleAddBlock = prop.getProperty("TitleAddBlock");
            TitleEditBlock = prop.getProperty("TitleEditBlock");
            BorderTextAddBlockWindow = prop.getProperty("BorderTextAddBlockWindow");
            LbUserWindow = prop.getProperty("LbUserWindow");
            LbWindowIsRunning = prop.getProperty("LbWindowIsRunning");
            LbKeyword = prop.getProperty("LbKeyword");
            JCheckBox1 = prop.getProperty("JCheckBox1");
            LbTimeFrom = prop.getProperty("LbTimeFrom");
            LbTimeEnd = prop.getProperty("LbTimeEnd");
            BtCancel = prop.getProperty("BtCancel");
            //Create Account
            TitleCreateAccount = prop.getProperty("TitleCreateAccount");
            LbInfoTab1 = prop.getProperty("LbInfoTab1");
            TitleTextTab1CreateAcount = prop.getProperty("TitleTextTab1CreateAcount");
            BorderTab1CreateAcount = prop.getProperty("BorderTab1CreateAcount");
            LbReEmail = prop.getProperty("LbReEmail");
            LbCode = prop.getProperty("LbCode");
            LbInfoTab2 = prop.getProperty("LbInfoTab2");
            TitleTextTab2CreateAcount = prop.getProperty("TitleTextTab2CreateAcount");
            BorderTab2CreateAcount = prop.getProperty("BorderTab2CreateAcount");
            JLabel5Account = prop.getProperty("JLabel5Account");
            JLabel6Account = prop.getProperty("JLabel6Account");
            JLabel7Account = prop.getProperty("JLabel7Account");
            BtSendEmail1 = prop.getProperty("BtSendEmail1");
            BtSendEmail2 = prop.getProperty("BtSendEmail2");
            BtSendEmail3 = prop.getProperty("BtSendEmail3");


            reader.close();

        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            try {
                input.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
        }
    }

    @Override
    public void windowOpened(WindowEvent e) {
    }

    @Override
    public void windowClosing(WindowEvent e) {
        login.txtPassword.setText("");
//        login.setVisible(true);
    }

    @Override
    public void windowClosed(WindowEvent e) {
    }

    @Override
    public void windowIconified(WindowEvent e) {
    }

    @Override
    public void windowDeiconified(WindowEvent e) {
    }

    @Override
    public void windowActivated(WindowEvent e) {
    }

    @Override
    public void windowDeactivated(WindowEvent e) {
    }

    class scheduleDailyTask1 extends TimerTask {

        public void run() {
            if (isRunning) {
                getCurrentWindow();
            }

        }
    }

    private void initEmail() {

        File fXmlFile = new File(filePath + File.separator + "fileEmail.xml");
        if (fXmlFile.exists() && !fXmlFile.isDirectory()) {
            ActiveEmail activeEmail = XmlFile4.readFileXml(filePath + File.separator + "fileEmail.xml");

            if (activeEmail.getActive().equals("1")) {
                btCreatePass.setText(activeEmail.getEmail());
            }

        }
    }

    //<editor-fold defaultstate="collapsed" desc="getCurrentWindow">
    public void getCurrentWindow() {

        isRunning = false;

        final String titleActive = EnumerateWindows.activeWindowTitle();
        String activeWindowTitle = EnumerateWindows.activeWindowTitle().toLowerCase();
        final String activeWindowProcess = EnumerateWindows.activeWindowProcess().toLowerCase();

        if (cbStartWithWindow.isSelected()) {
            if (activeWindowProcess.equals("chrome.exe")
                    || activeWindowProcess.equals("firefox.exe")
                    || activeWindowProcess.equals("iexplore.exe")) {

                for (final Application application : listApp) {
                    if (application.getType().equals("appTile")) {
                        if (application.getUser().toLowerCase().equals(user)
                                || application.getUser().equals("[All]")) {
                            if (application.getStart().trim().equals("")
                                    && application.getEnd().trim().equals("")) {

                                String title = StringUtil.joinString(StringUtil.cutString(activeWindowTitle));
                                if (title.contains(application.getWindow().toLowerCase())) {
                                    try {

                                        final String screenCapture = screenCapture();
                                        final String pathProcess = EnumerateWindows.getPathProcess(activeWindowProcess);
                                        EnumerateWindows.closeTabBrowser();

                                        new Thread(new Runnable() {
                                            @Override
                                            public void run() {
                                                writeHistory(application, titleActive, screenCapture, pathProcess);
                                            }
                                        }).run();

                                        isRunning = true;

                                        return;
                                    } catch (Exception ex) {
                                        ex.printStackTrace();
                                    }
                                }
                            } else {
                                if (DateUtil.checkTime(application.getStart(), application.getEnd())) {
                                    String title = StringUtil.joinString(StringUtil.cutString(activeWindowTitle));
                                    if (title.contains(application.getWindow().toLowerCase())) {
                                        try {
                                            final String screenCapture = screenCapture();
                                            final String pathProcess = EnumerateWindows.getPathProcess(activeWindowProcess);
                                            EnumerateWindows.closeTabBrowser();

                                            new Thread(new Runnable() {
                                                @Override
                                                public void run() {
                                                    writeHistory(application, titleActive, screenCapture, pathProcess);
                                                }
                                            }).run();

                                            isRunning = true;

                                            return;
                                        } catch (Exception ex) {
                                            ex.printStackTrace();
                                        }
                                    }
                                }

                            }
                        }
                    }

                }
            } else {

                for (final Application application : listApp) {
                    if (activeWindowTitle.contains(application.getWindow().toLowerCase())) {

                        if (application.getType().equals("appTile")) {

                            if (application.getUser().toLowerCase().equals(user)
                                    || application.getUser().equals("[All]")) {

                                if (application.getStart().trim().equals("")
                                        && application.getEnd().trim().equals("")) {
                                    try {
                                        if (EnumerateWindows.isProcessRunging(activeWindowProcess)) {

                                            final String screenCapture = screenCapture();
                                            final String pathProcess = EnumerateWindows.getPathProcess(activeWindowProcess);


                                            EnumerateWindows.killProcess(activeWindowProcess);

                                            new Thread(new Runnable() {
                                                @Override
                                                public void run() {
                                                    writeHistory(application, titleActive, screenCapture, pathProcess);
                                                }
                                            }).run();

                                            isRunning = true;

                                            return;
                                        }
                                    } catch (Exception ex) {
                                        ex.printStackTrace();
                                    }
                                } else {
                                    if (DateUtil.checkTime(application.getStart(), application.getEnd())) {
                                        try {
                                            if (EnumerateWindows.isProcessRunging(activeWindowProcess)) {

                                                final String screenCapture = screenCapture();
                                                final String pathProcess = EnumerateWindows.getPathProcess(activeWindowProcess);
                                                EnumerateWindows.killProcess(activeWindowProcess);

                                                new Thread(new Runnable() {
                                                    @Override
                                                    public void run() {
                                                        writeHistory(application, titleActive, screenCapture, pathProcess);
                                                    }
                                                }).run();

                                                isRunning = true;
                                                return;
                                            }
                                        } catch (Exception ex) {
                                            ex.printStackTrace();
                                        }
                                    }
                                }


                            }
                        }

                    }
                }

            }
        }



        if (EnumerateWindows.activeWindowProcess().toLowerCase().equals("firefox.exe")
                || EnumerateWindows.activeWindowProcess().toLowerCase().equals("iexplore.exe")) {
            if (cbBlockWeb.isSelected()) {



                //get url browser

                final String url = DDEClientUrlBrowser.getUrlBrowser(StringUtil.cutExe(EnumerateWindows.activeWindowProcess().toLowerCase()).get(0));
                if (url.contains("https://") || url.contains("http://")) {
                    boolean n = false;
//                    boolean t = false;
                    for (Application application : listApp) {
                        if (application.getType().equals("site")) {
                            if (application.getUser().toLowerCase().equals(user)
                                    || application.getUser().equals("[All]")) {
                                if (application.getStart().trim().equals("")
                                        && application.getEnd().trim().equals("")) {
//                                    t = true;
                                    if (url.contains(application.getWindow().toLowerCase())) {
                                        n = true;
                                        break;
                                    }
                                } else {
                                    if (DateUtil.checkTime(application.getStart(), application.getEnd())) {
//                                        t = true;
                                        if (url.contains(application.getWindow().toLowerCase())) {
                                            n = true;
                                            break;
                                        }
                                    }
                                }

                            }
                        }

                    }



//                    System.out.println("phat"+n);

                    if (n == false) {
                        try {
                            final String screenCapture = screenCapture();

                            EnumerateWindows.closeTabBrowser();

                            new Thread(new Runnable() {
                                @Override
                                public void run() {
                                    ApplicationAccessed applicationAccessed = new ApplicationAccessed();
                                    applicationAccessed.setWindow(titleActive);
                                    applicationAccessed.setUser(user);
                                    applicationAccessed.setType("site");
                                    applicationAccessed.setKeyword("");
                                    applicationAccessed.setUrl(url);
                                    applicationAccessed.setImage(screenCapture);
                                    applicationAccessed.setPathProcess("");

                                    File fXmlFile = new File(filePath + File.separator + "fileHistory.xml");
                                    if (!fXmlFile.exists()) {
                                        XmlFile3.createXmlNew(filePath + File.separator + "fileHistory.xml", applicationAccessed);
                                    } else if (fXmlFile.exists() && !fXmlFile.isDirectory()) {
                                        XmlFile3.createXmlExist(filePath + File.separator + "fileHistory.xml", applicationAccessed);
                                    }
                                }
                            }).run();

                            isRunning = true;

                            return;
                        } catch (Exception ex) {
                            ex.printStackTrace();
                        }
                    }


                }
            }


        }

        isRunning = true;
    }
    //</editor-fold>

    private void writeHistory(Application application, String titleActive, String image, String pathProcess) {
        ApplicationAccessed applicationAccessed = new ApplicationAccessed();
        applicationAccessed.setWindow(titleActive);
        applicationAccessed.setUser(user);
        applicationAccessed.setType(application.getType());
        applicationAccessed.setKeyword(application.getWindow());
        applicationAccessed.setUrl("");
        applicationAccessed.setImage(image);
        applicationAccessed.setPathProcess(pathProcess);


        File fXmlFile = new File(filePath + File.separator + "fileHistory.xml");
        if (!fXmlFile.exists()) {
            XmlFile3.createXmlNew(filePath + File.separator + "fileHistory.xml", applicationAccessed);
        } else if (fXmlFile.exists() && !fXmlFile.isDirectory()) {
            XmlFile3.createXmlExist(filePath + File.separator + "fileHistory.xml", applicationAccessed);
        }
    }

    private String screenCapture() throws AWTException, IOException {
        Date d1 = new Date();
        SimpleDateFormat simpDate = new SimpleDateFormat("yyyyMMddHHmmss");
        String name2 = simpDate.format(d1);

        Robot robot = new Robot();
        Rectangle screenRect = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
        BufferedImage capture = robot.createScreenCapture(screenRect);

        ImageIO.write(capture, "jpg", new File(filePath + File.separator + name2 + ".jpg"));

        return name2 + ".jpg";
    }

    private void initTabPanel() {
        Image image = new ImageIcon(getClass().getResource("/img/lock.png")).getImage();

        Image scaledInstance = image.getScaledInstance(30,
                30, Image.SCALE_SMOOTH);

        ImageIcon icon = new ImageIcon(scaledInstance);

        jTabbedPane1.setTitleAt(0, HeaderTab1);
        jTabbedPane1.setIconAt(0, icon);


        image = new ImageIcon(getClass().getResource("/img/permission.png")).getImage();

        scaledInstance = image.getScaledInstance(30,
                30, Image.SCALE_SMOOTH);

        icon = new ImageIcon(scaledInstance);

        jTabbedPane1.setTitleAt(1, HeaderTab2);
        jTabbedPane1.setIconAt(1, icon);


        image = new ImageIcon(getClass().getResource("/img/blockAccessed.png")).getImage();

        scaledInstance = image.getScaledInstance(30,
                30, Image.SCALE_SMOOTH);

        icon = new ImageIcon(scaledInstance);

        jTabbedPane1.setTitleAt(2, HeaderTab3);
        jTabbedPane1.setIconAt(2, icon);

        image = new ImageIcon(getClass().getResource("/img/monitorAccess.png")).getImage();

        scaledInstance = image.getScaledInstance(30,
                30, Image.SCALE_SMOOTH);

        icon = new ImageIcon(scaledInstance);

        jTabbedPane1.setTitleAt(3, HeaderTab4);
        jTabbedPane1.setIconAt(3, icon);


    }

    //<editor-fold defaultstate="collapsed" desc="initTable1">
    private void initTable1() {
        //khong cho column di chuyen
        table1.getTableHeader().setReorderingAllowed(false);

        //set width column
        table1.getColumn("Id").setMinWidth(0);
        table1.getColumn("Id").setMaxWidth(0);
        table1.getColumn("Id").setWidth(0);

        table1.setShowGrid(false);
        table1.setIntercellSpacing(new Dimension(0, 0));

//        table1.setTableHeader(null);


        TableUtil.clearTable(dmodel1);

        TableUtil.sortTable(dmodel1, table1, sorter);

        searchAllTable1();

    }
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc="initTable2">
    private void initTable2() {
        //khong cho column di chuyen
        table2.getTableHeader().setReorderingAllowed(false);

        //set width column
        table2.getColumn("Id").setMinWidth(0);
        table2.getColumn("Id").setMaxWidth(0);
        table2.getColumn("Id").setWidth(0);

        table2.setShowGrid(false);
        table2.setIntercellSpacing(new Dimension(0, 0));

//        table1.setTableHeader(null);


        TableUtil.clearTable(dmodel2);

        TableUtil.sortTable(dmodel2, table2, sorter);

        searchAllTable2();

    }
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc="initTable3">
    private void initTable3() {
        //khong cho column di chuyen
        table3.getTableHeader().setReorderingAllowed(false);

        //set width column
        table3.getColumn("Id").setMinWidth(0);
        table3.getColumn("Id").setMaxWidth(0);
        table3.getColumn("Id").setWidth(0);

        table3.getColumn("Type").setMinWidth(0);
        table3.getColumn("Type").setMaxWidth(0);
        table3.getColumn("Type").setWidth(0);

        table3.getColumn("Address").setMinWidth(0);
        table3.getColumn("Address").setMaxWidth(0);
        table3.getColumn("Address").setWidth(0);

        table3.getColumn("Keyword").setMinWidth(0);
        table3.getColumn("Keyword").setMaxWidth(0);
        table3.getColumn("Keyword").setWidth(0);

        table3.getColumn("Image").setMinWidth(0);
        table3.getColumn("Image").setMaxWidth(0);
        table3.getColumn("Image").setWidth(0);

        table3.getColumn("PathProcess").setMinWidth(0);
        table3.getColumn("PathProcess").setMaxWidth(0);
        table3.getColumn("PathProcess").setWidth(0);

        table3.setShowGrid(false);
        table3.setIntercellSpacing(new Dimension(0, 0));

//        table1.setTableHeader(null);


        TableUtil.clearTable(dmodel3);

        TableUtil.sortTable(dmodel3, table3, sorter);

        searchAllTable3();

    }
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc="initTable4">
    private void initTable4() {
        //khong cho column di chuyen
        table4.getTableHeader().setReorderingAllowed(false);

        //set width column
        table4.getColumn("Id").setMinWidth(0);
        table4.getColumn("Id").setMaxWidth(0);
        table4.getColumn("Id").setWidth(0);

        table4.getColumn("Type").setMinWidth(0);
        table4.getColumn("Type").setMaxWidth(0);
        table4.getColumn("Type").setWidth(0);

        table4.getColumn("Address").setMinWidth(0);
        table4.getColumn("Address").setMaxWidth(0);
        table4.getColumn("Address").setWidth(0);

        table4.getColumn("Keyword").setMinWidth(0);
        table4.getColumn("Keyword").setMaxWidth(0);
        table4.getColumn("Keyword").setWidth(0);

        table4.setShowGrid(false);
        table4.setIntercellSpacing(new Dimension(0, 0));

//        table1.setTableHeader(null);


        TableUtil.clearTable(dmodel4);

        TableUtil.sortTable(dmodel4, table4, sorter);


        new Thread(new Runnable() {
            @Override
            public void run() {
                searchAllTable4();
            }
        }).start();


    }
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc="initCheckBoxBlockWeb">
    private void initCheckBoxBlockWeb() {
        String readFileXml = XmlFile2.readFileXml(filePath + File.separator + "fileCondition.xml");
        if (!readFileXml.equals("")) {
            if (readFileXml.equals("true")) {
                cbBlockWeb.setSelected(true);
            } else if (readFileXml.equals("false")) {
                cbBlockWeb.setSelected(false);
            }
        } else {
            cbBlockWeb.setSelected(false);

        }
    }
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc="initCheckBoxStartWithWindow">
    private void initCheckBoxStartWithWindow() {
        String readFileXml = XmlFile5.readFileXml(filePath + File.separator + "fileStartWithWindow.xml");
        if (!readFileXml.equals("")) {
            if (readFileXml.equals("true")) {
                cbStartWithWindow.setSelected(true);
            } else if (readFileXml.equals("false")) {
                cbStartWithWindow.setSelected(false);
            }
        } else {
            cbStartWithWindow.setSelected(false);

        }
    }
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc="creatTable1">
    private void creatTable1() {

        Object rows[][] = {};
        Object headers[] = {"Id", Window, User, Start, End};
        dmodel1 = new ModelTable(rows, headers);
        dmodel1.setCanEdit(new boolean[]{false, false, false, false, false});
        dmodel1.setTypes(new Class[]{String.class, String.class, String.class, String.class, String.class});

    }
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc="creatTable2">
    private void creatTable2() {

        Object rows[][] = {};
        Object headers[] = {"Id", Web, User, Start, End};
        dmodel2 = new ModelTable(rows, headers);
        dmodel2.setCanEdit(new boolean[]{false, false, false, false, false});
        dmodel2.setTypes(new Class[]{String.class, String.class, String.class, String.class, String.class});

    }
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc="creatTable3">
    private void creatTable3() {

        Object rows[][] = {};
        Object headers[] = {"Id", Window, User, Date, Time, "Type", "Address", "Keyword", "Image", "PathProcess"};
        dmodel3 = new ModelTable(rows, headers);
        dmodel3.setCanEdit(new boolean[]{false, false, false, false, false, false, false, false, false, false});
        dmodel3.setTypes(new Class[]{String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class});

    }
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc="creatTable4">
    private void creatTable4() {

        Object rows[][] = {};
        Object headers[] = {"Id", Window, User, Date, Time, "Type", "Address", "Keyword"};
        dmodel4 = new ModelTable(rows, headers);
        dmodel4.setCanEdit(new boolean[]{false, false, false, false, false, false, false, false});
        dmodel4.setTypes(new Class[]{String.class, String.class, String.class, String.class, String.class, String.class, String.class, String.class});

    }
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc="searchAllTable1">
    public void searchAllTable1() {

        TableUtil.clearTable(dmodel1);

        List<Application> list = XmlFile.readFileXml(filePath + File.separator + "file.xml");

        for (Application application : list) {
            if (application.getType().equals("appTile")) {

                dmodel1.insertRow(dmodel1.getRowCount(), new Object[]{
                            application.getId(),
                            application.getWindow(),
                            application.getUser(),
                            application.getStart(),
                            application.getEnd()
                        });
            }

        }

    }
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc="searchAllTable2">
    public void searchAllTable2() {

        TableUtil.clearTable(dmodel2);

        List<Application> list = XmlFile.readFileXml(filePath + File.separator + "file.xml");

        for (Application application : list) {
            if (application.getType().equals("site")) {

                dmodel2.insertRow(dmodel2.getRowCount(), new Object[]{
                            application.getId(),
                            application.getWindow(),
                            application.getUser(),
                            application.getStart(),
                            application.getEnd()
                        });
            }

        }

    }
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc="searchAllTable3">
    public void searchAllTable3() {

        TableUtil.clearTable(dmodel3);

        list3 = XmlFile3.readFileXml(filePath + File.separator + "fileHistory.xml");

        for (ApplicationAccessed applicationAccessed : list3) {
            dmodel3.insertRow(dmodel3.getRowCount(), new Object[]{
                        applicationAccessed.getId(),
                        applicationAccessed.getWindow(),
                        applicationAccessed.getUser(),
                        applicationAccessed.getDate(),
                        applicationAccessed.getHours(),
                        applicationAccessed.getType(),
                        applicationAccessed.getUrl(),
                        applicationAccessed.getKeyword(),
                        applicationAccessed.getImage(),
                        applicationAccessed.getPathProcess()
                    });


        }



    }
    //</editor-fold>

    //<editor-fold defaultstate="collapsed" desc="searchAllTable4">
    public void searchAllTable4() {

        TableUtil.clearTable(dmodel4);

        list4 = XmlFile3.readFileXml(filePath + File.separator + "fileHistory.xml");

        for (ApplicationAccessed applicationAccessed : list4) {
            dmodel4.insertRow(dmodel4.getRowCount(), new Object[]{
                        applicationAccessed.getId(),
                        applicationAccessed.getWindow(),
                        applicationAccessed.getUser(),
                        applicationAccessed.getDate(),
                        applicationAccessed.getHours(),
                        applicationAccessed.getType(),
                        applicationAccessed.getUrl(),
                        applicationAccessed.getKeyword()
                    });
        }

    }
    //</editor-fold>

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jCheckBox2 = new javax.swing.JCheckBox();
        buttonGroup1 = new javax.swing.ButtonGroup();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        cbStartWithWindow = new javax.swing.JCheckBox();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        table1 = new javax.swing.JTable();
        btAddApp = new javax.swing.JLabel();
        btEditApp = new javax.swing.JLabel();
        btRemoveApp = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        cbBlockWeb = new javax.swing.JCheckBox();
        jPanel8 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        table2 = new javax.swing.JTable();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        jLabel25 = new javax.swing.JLabel();
        jLabel26 = new javax.swing.JLabel();
        btRemoveWeb = new javax.swing.JLabel();
        btEditWeb = new javax.swing.JLabel();
        btAddSite = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        jPanel10 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        table3 = new JTable(dmodel3) {
            public String getToolTipText(MouseEvent e) {
                String tip = null;
                java.awt.Point p = e.getPoint();
                int rowIndex = rowAtPoint(p);
                int colIndex = columnAtPoint(p);
                int realColumnIndex = convertColumnIndexToModel(colIndex);

                if (realColumnIndex == 1 || realColumnIndex == 2
                    || realColumnIndex == 3 || realColumnIndex == 4) { //Sport column
                    TableModel model = getModel();
                    String window = (String) model.getValueAt(rowIndex, 1);
                    String keyword = (String) model.getValueAt(rowIndex, 7);
                    String rule = (String) model.getValueAt(rowIndex, 1);
                    String type = (String) model.getValueAt(rowIndex, 5);
                    String url = (String) model.getValueAt(rowIndex, 6);
                    if (type.equals("site")) {
                        tip = "<html>"
                        + "<font color=\"blue\">Janela: </font>" + window
                        + "<br><font color=\"blue\">Endereço: </font>" + url
                        + "<br><font color=\"blue\">Regra: </font>" + "\"Não consta na lista de sites liberados\"";
                    } else {
                        tip = "<html>"
                        + "<font color=\"blue\">Janela: </font>" + window
                        + "<br><font color=\"blue\">Palavra-chave: </font>" + keyword
                        + "<br><font color=\"blue\">Regra: </font>" + StringUtil.boldString(window, keyword);
                    }

                } else {
                    //You can omit this part if you know you don't
                    //have any renderers that supply their own tool
                    //tips.
                    tip = super.getToolTipText(e);
                }
                return tip;
            }
        };
        jLabel30 = new javax.swing.JLabel();
        jLabel31 = new javax.swing.JLabel();
        btViewHistory = new javax.swing.JLabel();
        jLabel33 = new javax.swing.JLabel();
        jLabel34 = new javax.swing.JLabel();
        btRemoveBlock = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jPanel12 = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        table4 = new javax.swing.JTable(dmodel4) {
            public String getToolTipText(MouseEvent e) {
                String tip = null;
                java.awt.Point p = e.getPoint();
                int rowIndex = rowAtPoint(p);
                int colIndex = columnAtPoint(p);
                int realColumnIndex = convertColumnIndexToModel(colIndex);

                if (realColumnIndex == 1 || realColumnIndex == 2
                    || realColumnIndex == 3 || realColumnIndex == 4) { //Sport column
                    TableModel model = getModel();
                    String window = (String) model.getValueAt(rowIndex, 1);
                    String keyword = (String) model.getValueAt(rowIndex, 7);
                    String rule = (String) model.getValueAt(rowIndex, 1);
                    String type = (String) model.getValueAt(rowIndex, 5);
                    String url = (String) model.getValueAt(rowIndex, 6);
                    if (type.equals("site")) {
                        tip = "<html>"
                        + "<font color=\"blue\">Janela: </font>" + window
                        + "<br><font color=\"blue\">Endereço: </font>" + url
                        + "<br><font color=\"blue\">Regra: </font>" + "\"Não consta na lista de sites liberados\"";
                    } else {
                        tip = "<html>"
                        + "<font color=\"blue\">Janela: </font>" + window
                        + "<br><font color=\"blue\">Palavra-chave: </font>" + keyword
                        + "<br><font color=\"blue\">Regra: </font>" + StringUtil.boldString(window, keyword);
                    }

                } else {
                    //You can omit this part if you know you don't
                    //have any renderers that supply their own tool
                    //tips.
                    tip = super.getToolTipText(e);
                }
                return tip;
            }
        };
        jLabel36 = new javax.swing.JLabel();
        jLabel37 = new javax.swing.JLabel();
        jLabel38 = new javax.swing.JLabel();
        jLabel39 = new javax.swing.JLabel();
        jLabel40 = new javax.swing.JLabel();
        jLabel41 = new javax.swing.JLabel();
        jPanel6 = new javax.swing.JPanel();
        jPanel13 = new javax.swing.JPanel();
        btCreatePass = new javax.swing.JLabel();
        jRadioButton1 = new javax.swing.JRadioButton();
        jRadioButton2 = new javax.swing.JRadioButton();
        jPanel14 = new javax.swing.JPanel();
        jLabel17 = new javax.swing.JLabel();
        jPanel15 = new javax.swing.JPanel();

        jCheckBox2.setText("jCheckBox2");

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("GUARDIÃO EXCLUSIVO");
        setBackground(new java.awt.Color(245, 245, 245));
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        jTabbedPane1.setTabPlacement(javax.swing.JTabbedPane.BOTTOM);
        jTabbedPane1.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jTabbedPane1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTabbedPane1MouseClicked(evt);
            }
        });

        jPanel1.setBackground(new java.awt.Color(255, 255, 255));

        cbStartWithWindow.setBackground(new java.awt.Color(255, 255, 255));
        cbStartWithWindow.setText(CbStartWithWindow);
        cbStartWithWindow.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbStartWithWindowActionPerformed(evt);
            }
        });

        jPanel5.setBackground(new java.awt.Color(255, 255, 255));
        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createTitledBorder(null, BorderTextTab1, javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 12))));
        jPanel5.setMaximumSize(new java.awt.Dimension(569, 165));
        jPanel5.setMinimumSize(new java.awt.Dimension(569, 165));
        jPanel5.setPreferredSize(new java.awt.Dimension(569, 165));

        jScrollPane1.setBackground(new java.awt.Color(255, 255, 255));

        table1.setModel(dmodel1);
        table1.setMaximumSize(new java.awt.Dimension(300, 64));
        table1.setMinimumSize(new java.awt.Dimension(300, 64));
        table1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                table1MouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(table1);

        btAddApp.setForeground(new java.awt.Color(0, 153, 204));
        btAddApp.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        btAddApp.setText(BtAddApp);
        btAddApp.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btAddApp.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btAddAppMouseClicked(evt);
            }
        });

        btEditApp.setForeground(new java.awt.Color(0, 153, 204));
        btEditApp.setText(BtEditApp);
        btEditApp.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btEditApp.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btEditAppMouseClicked(evt);
            }
        });

        btRemoveApp.setForeground(new java.awt.Color(0, 153, 204));
        btRemoveApp.setText(BtRemoveApp);
        btRemoveApp.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btRemoveApp.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btRemoveAppMouseClicked(evt);
            }
        });

        jLabel4.setForeground(new java.awt.Color(0, 153, 204));
        jLabel4.setText("Test");
        jLabel4.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jLabel4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabel4MouseClicked(evt);
            }
        });

        jLabel18.setBackground(new java.awt.Color(255, 255, 255));
        jLabel18.setForeground(new java.awt.Color(255, 255, 255));
        jLabel18.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel18.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/i_add.JPG"))); // NOI18N
        jLabel18.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jLabel18.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jLabel18.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        jLabel19.setBackground(new java.awt.Color(255, 255, 255));
        jLabel19.setForeground(new java.awt.Color(255, 255, 255));
        jLabel19.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel19.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/i_edit.JPG"))); // NOI18N
        jLabel19.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jLabel19.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jLabel19.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        jLabel20.setBackground(new java.awt.Color(255, 255, 255));
        jLabel20.setForeground(new java.awt.Color(255, 255, 255));
        jLabel20.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel20.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/i_remove.JPG"))); // NOI18N
        jLabel20.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jLabel20.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jLabel20.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        jLabel21.setBackground(new java.awt.Color(255, 255, 255));
        jLabel21.setForeground(new java.awt.Color(255, 255, 255));
        jLabel21.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel21.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/i_test.JPG"))); // NOI18N
        jLabel21.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jLabel21.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jLabel21.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel18, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel19, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel20, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel21, javax.swing.GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btEditApp, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btRemoveApp, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(btAddApp, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 34, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 436, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel5Layout.createSequentialGroup()
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(btAddApp, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel18, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel19, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btEditApp, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel20, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btRemoveApp, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(15, 15, 15)
                        .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel21, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE))))
                .addContainerGap(40, Short.MAX_VALUE))
        );

        jLabel4.setVisible(false);
        jLabel21.setVisible(false);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cbStartWithWindow)
                    .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, 601, Short.MAX_VALUE))
                .addContainerGap(43, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(cbStartWithWindow)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
                .addContainerGap(28, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Bloqueios", jPanel1);

        jPanel2.setBackground(new java.awt.Color(255, 255, 255));

        cbBlockWeb.setBackground(new java.awt.Color(255, 255, 255));
        cbBlockWeb.setText(CbBlockWeb);
        cbBlockWeb.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbBlockWebActionPerformed(evt);
            }
        });

        jPanel8.setBackground(new java.awt.Color(255, 255, 255));
        jPanel8.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createTitledBorder(null, BorderTextTab2, javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 12))));
        jPanel8.setMaximumSize(new java.awt.Dimension(569, 165));
        jPanel8.setMinimumSize(new java.awt.Dimension(569, 165));

        table2.setModel(dmodel2);
        table2.setMaximumSize(new java.awt.Dimension(300, 64));
        table2.setMinimumSize(new java.awt.Dimension(300, 64));
        jScrollPane2.setViewportView(table2);

        jLabel22.setBackground(new java.awt.Color(255, 255, 255));
        jLabel22.setForeground(new java.awt.Color(255, 255, 255));
        jLabel22.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel22.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/i_add.JPG"))); // NOI18N
        jLabel22.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jLabel22.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jLabel22.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        jLabel23.setBackground(new java.awt.Color(255, 255, 255));
        jLabel23.setForeground(new java.awt.Color(255, 255, 255));
        jLabel23.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel23.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/i_edit.JPG"))); // NOI18N
        jLabel23.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jLabel23.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jLabel23.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        jLabel24.setBackground(new java.awt.Color(255, 255, 255));
        jLabel24.setForeground(new java.awt.Color(255, 255, 255));
        jLabel24.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel24.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/i_remove.JPG"))); // NOI18N
        jLabel24.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jLabel24.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jLabel24.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        jLabel25.setBackground(new java.awt.Color(255, 255, 255));
        jLabel25.setForeground(new java.awt.Color(255, 255, 255));
        jLabel25.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel25.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/i_test.JPG"))); // NOI18N
        jLabel25.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jLabel25.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jLabel25.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        jLabel26.setForeground(new java.awt.Color(0, 153, 204));
        jLabel26.setText("Test");
        jLabel26.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jLabel26.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabel26MouseClicked(evt);
            }
        });
        jLabel26.setVisible(false);

        btRemoveWeb.setForeground(new java.awt.Color(0, 153, 204));
        btRemoveWeb.setText(BtRemoveWeb);
        btRemoveWeb.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btRemoveWeb.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btRemoveWebMouseClicked(evt);
            }
        });

        btEditWeb.setForeground(new java.awt.Color(0, 153, 204));
        btEditWeb.setText(BtEditWeb);
        btEditWeb.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btEditWeb.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btEditWebMouseClicked(evt);
            }
        });

        btAddSite.setForeground(new java.awt.Color(0, 153, 204));
        btAddSite.setText(BtAddSite);
        btAddSite.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btAddSite.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btAddSiteMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createSequentialGroup()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel22, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel23, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel24, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel25, javax.swing.GroupLayout.DEFAULT_SIZE, 45, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(btEditWeb, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btRemoveWeb, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel26, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(btAddSite, javax.swing.GroupLayout.PREFERRED_SIZE, 47, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane2)
                .addContainerGap())
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(btAddSite, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel22))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel23, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btEditWeb, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel24, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btRemoveWeb, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel25, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel26, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addGap(0, 65, Short.MAX_VALUE))
        );

        jLabel25.setVisible(false);

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(cbBlockWeb)
                    .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(43, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(cbBlockWeb)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap(28, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Permissões", jPanel2);

        jPanel3.setBackground(new java.awt.Color(255, 255, 255));
        jPanel3.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jPanel3MouseClicked(evt);
            }
        });

        jPanel10.setBackground(new java.awt.Color(255, 255, 255));
        jPanel10.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createTitledBorder(null, BorderTextTab3, javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 12))));
        jPanel10.setMaximumSize(new java.awt.Dimension(569, 165));
        jPanel10.setMinimumSize(new java.awt.Dimension(569, 165));

        jScrollPane3.setViewportView(table3);

        jLabel30.setBackground(new java.awt.Color(255, 255, 255));
        jLabel30.setForeground(new java.awt.Color(255, 255, 255));
        jLabel30.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel30.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/i_view.JPG"))); // NOI18N
        jLabel30.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jLabel30.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jLabel30.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        jLabel31.setForeground(new java.awt.Color(0, 153, 204));
        jLabel31.setText(JLabel31);
        jLabel31.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jLabel31.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabel31MouseClicked(evt);
            }
        });

        btViewHistory.setForeground(new java.awt.Color(0, 153, 204));
        btViewHistory.setText(BtViewHistory);
        btViewHistory.setToolTipText("");
        btViewHistory.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btViewHistory.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btViewHistoryMouseClicked(evt);
            }
        });

        jLabel33.setBackground(new java.awt.Color(255, 255, 255));
        jLabel33.setForeground(new java.awt.Color(255, 255, 255));
        jLabel33.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel33.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/i_export.JPG"))); // NOI18N
        jLabel33.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jLabel33.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jLabel33.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        jLabel34.setBackground(new java.awt.Color(255, 255, 255));
        jLabel34.setForeground(new java.awt.Color(255, 255, 255));
        jLabel34.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel34.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/i_remove.JPG"))); // NOI18N
        jLabel34.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jLabel34.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jLabel34.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        btRemoveBlock.setForeground(new java.awt.Color(0, 153, 204));
        btRemoveBlock.setText(BtRemoveBlock);
        btRemoveBlock.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        btRemoveBlock.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btRemoveBlockMouseClicked(evt);
            }
        });

        javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
        jPanel10.setLayout(jPanel10Layout);
        jPanel10Layout.setHorizontalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel10Layout.createSequentialGroup()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel30, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel33, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel34, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(btRemoveBlock)
                    .addComponent(btViewHistory, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel31, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 469, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel10Layout.setVerticalGroup(
            jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel10Layout.createSequentialGroup()
                .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel10Layout.createSequentialGroup()
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(btViewHistory, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel30))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel33, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel31, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel34, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(btRemoveBlock, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(0, 68, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap(43, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap(31, Short.MAX_VALUE)
                .addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(26, 26, 26))
        );

        jTabbedPane1.addTab("Acessos bloqueados", jPanel3);

        jPanel4.setBackground(new java.awt.Color(255, 255, 255));
        jPanel4.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jPanel4MouseClicked(evt);
            }
        });

        jPanel12.setBackground(new java.awt.Color(255, 255, 255));
        jPanel12.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createTitledBorder(null, BorderTextTab4, javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 12))));
        jPanel12.setMaximumSize(new java.awt.Dimension(569, 165));
        jPanel12.setMinimumSize(new java.awt.Dimension(569, 165));

        jScrollPane4.setViewportView(table4);

        jLabel36.setForeground(new java.awt.Color(0, 153, 204));
        jLabel36.setText(BtViewHistory);
        jLabel36.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jLabel36.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabel36MouseClicked(evt);
            }
        });

        jLabel37.setBackground(new java.awt.Color(255, 255, 255));
        jLabel37.setForeground(new java.awt.Color(255, 255, 255));
        jLabel37.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel37.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/i_view.JPG"))); // NOI18N
        jLabel37.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jLabel37.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jLabel37.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        jLabel38.setBackground(new java.awt.Color(255, 255, 255));
        jLabel38.setForeground(new java.awt.Color(255, 255, 255));
        jLabel38.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel38.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/i_export.JPG"))); // NOI18N
        jLabel38.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jLabel38.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jLabel38.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        jLabel39.setForeground(new java.awt.Color(0, 153, 204));
        jLabel39.setText(BtRemoveBlock);
        jLabel39.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jLabel39.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabel39MouseClicked(evt);
            }
        });

        jLabel40.setForeground(new java.awt.Color(0, 153, 204));
        jLabel40.setText(JLabel31);
        jLabel40.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        jLabel40.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jLabel40MouseClicked(evt);
            }
        });

        jLabel41.setBackground(new java.awt.Color(255, 255, 255));
        jLabel41.setForeground(new java.awt.Color(255, 255, 255));
        jLabel41.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel41.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/i_remove.JPG"))); // NOI18N
        jLabel41.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jLabel41.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        jLabel41.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);

        javax.swing.GroupLayout jPanel12Layout = new javax.swing.GroupLayout(jPanel12);
        jPanel12.setLayout(jPanel12Layout);
        jPanel12Layout.setHorizontalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel12Layout.createSequentialGroup()
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel37, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel38, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel41, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jLabel40, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel39, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jLabel36))
                .addGap(21, 21, 21)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 466, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel12Layout.setVerticalGroup(
            jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel12Layout.createSequentialGroup()
                .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel12Layout.createSequentialGroup()
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel36, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel37))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel38, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel40, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel12Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jLabel41, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel39, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(0, 68, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap(43, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap(31, Short.MAX_VALUE)
                .addComponent(jPanel12, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(26, 26, 26))
        );

        jTabbedPane1.addTab("Monitor de acessos", jPanel4);

        jPanel6.setBackground(new java.awt.Color(245, 245, 245));
        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 16, Short.MAX_VALUE)
        );

        jPanel13.setBackground(new java.awt.Color(245, 245, 245));
        jPanel13.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        btCreatePass.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        btCreatePass.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        btCreatePass.setText(BtCreatePass);
        btCreatePass.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                btCreatePassMouseClicked(evt);
            }
        });

        buttonGroup1.add(jRadioButton1);
        jRadioButton1.setText("Portugal");
        jRadioButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton1ActionPerformed(evt);
            }
        });

        buttonGroup1.add(jRadioButton2);
        jRadioButton2.setText("English");
        jRadioButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jRadioButton2ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel13Layout = new javax.swing.GroupLayout(jPanel13);
        jPanel13.setLayout(jPanel13Layout);
        jPanel13Layout.setHorizontalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel13Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jRadioButton1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jRadioButton2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(btCreatePass, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        jPanel13Layout.setVerticalGroup(
            jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel13Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(btCreatePass, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(jRadioButton1)
                .addComponent(jRadioButton2))
        );

        if(langPo){
            jRadioButton1.setSelected(true);
        }
        if(!langPo){
            jRadioButton2.setSelected(true);
        }

        jPanel14.setBackground(new java.awt.Color(245, 245, 245));

        jLabel17.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/logo.png"))); // NOI18N

        jPanel15.setBackground(new java.awt.Color(228, 131, 39));

        javax.swing.GroupLayout jPanel15Layout = new javax.swing.GroupLayout(jPanel15);
        jPanel15.setLayout(jPanel15Layout);
        jPanel15Layout.setHorizontalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 12, Short.MAX_VALUE)
        );
        jPanel15Layout.setVerticalGroup(
            jPanel15Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 0, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jPanel14Layout = new javax.swing.GroupLayout(jPanel14);
        jPanel14.setLayout(jPanel14Layout);
        jPanel14Layout.setHorizontalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel14Layout.createSequentialGroup()
                .addComponent(jPanel15, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel17, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel14Layout.setVerticalGroup(
            jPanel14Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jLabel17, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanel15, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanel13, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jPanel14, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel13, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel14, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 272, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void cbStartWithWindowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbStartWithWindowActionPerformed

        if (cbStartWithWindow.isSelected()) {

            File fXmlFile = new File(filePath + File.separator + "fileStartWithWindow.xml");

            if (fXmlFile.exists() && !fXmlFile.isDirectory()) {
                XmlFile5.editXml(filePath + File.separator + "fileStartWithWindow.xml", new BlockCondition("true"));

            } else if (!fXmlFile.exists()) {
                XmlFile5.createXmlNew(filePath + File.separator + "fileStartWithWindow.xml", new BlockCondition("true"));
            }


        } else {
            File fXmlFile = new File(filePath + File.separator + "fileStartWithWindow.xml");

            if (fXmlFile.exists() && !fXmlFile.isDirectory()) {
                XmlFile5.editXml(filePath + File.separator + "fileStartWithWindow.xml", new BlockCondition("false"));

            } else if (!fXmlFile.exists()) {
                XmlFile5.createXmlNew(filePath + File.separator + "fileStartWithWindow.xml", new BlockCondition("false"));
            }
        }

    }//GEN-LAST:event_cbStartWithWindowActionPerformed

    private void cbBlockWebActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbBlockWebActionPerformed
        if (cbBlockWeb.isSelected()) {

            File fXmlFile = new File(filePath + File.separator + "fileCondition.xml");

            if (fXmlFile.exists() && !fXmlFile.isDirectory()) {
                XmlFile2.editXml(filePath + File.separator + "fileCondition.xml", new BlockCondition("true"));

            } else if (!fXmlFile.exists()) {
                XmlFile2.createXmlNew(filePath + File.separator + "fileCondition.xml", new BlockCondition("true"));
            }


        } else {
            File fXmlFile = new File(filePath + File.separator + "fileCondition.xml");

            if (fXmlFile.exists() && !fXmlFile.isDirectory()) {
                XmlFile2.editXml(filePath + File.separator + "fileCondition.xml", new BlockCondition("false"));

            } else if (!fXmlFile.exists()) {
                XmlFile2.createXmlNew(filePath + File.separator + "fileCondition.xml", new BlockCondition("false"));
            }
        }


    }//GEN-LAST:event_cbBlockWebActionPerformed

    private void btAddAppMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btAddAppMouseClicked

        AddBlockWindowDialog ad = new AddBlockWindowDialog(this, "1");
        ad.setVisible(true);

    }//GEN-LAST:event_btAddAppMouseClicked

    private void jLabel4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel4MouseClicked
//        RunBlockWindowDialog runBlockWindowDialog = new RunBlockWindowDialog(this);
//        runBlockWindowDialog.setVisible(true);
    }//GEN-LAST:event_jLabel4MouseClicked

    private void table1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_table1MouseClicked
    }//GEN-LAST:event_table1MouseClicked

    private void btRemoveAppMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btRemoveAppMouseClicked

        isRunning = false;

        int r = table1.getSelectedRow();

        if (r > -1) {
            String id = table1.getModel().getValueAt(r, 0).toString();

            XmlFile.removeXml(filePath + File.separator + "file.xml", id);

            dmodel1.removeRow(r);
        }

        listApp = new ArrayList<Application>();
        listApp = XmlFile.readFileXml(filePath + File.separator + "file.xml");

        isRunning = true;

    }//GEN-LAST:event_btRemoveAppMouseClicked

    private void btEditAppMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btEditAppMouseClicked

        int r = table1.getSelectedRow();

        if (r > -1) {

            List<Application> list = XmlFile.readFileXml(filePath + File.separator + "file.xml");
            String id = table1.getModel().getValueAt(r, 0).toString();


            Application app = new Application();

            for (Application application : list) {

                if (application.getId().equals(id)) {

                    app = application;
                    System.out.println(app);
                    break;
                }
            }

//            String window = table1.getModel().getValueAt(r, 1).toString();
            AddBlockWindowDialog ad = new AddBlockWindowDialog(this, app, "1");
            ad.setVisible(true);
        }



    }//GEN-LAST:event_btEditAppMouseClicked

    private void btAddSiteMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btAddSiteMouseClicked
        AddBlockWindowDialog ad = new AddBlockWindowDialog(this, "2");
        ad.setVisible(true);
    }//GEN-LAST:event_btAddSiteMouseClicked

    private void btRemoveWebMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btRemoveWebMouseClicked
        isRunning = false;
        int r = table2.getSelectedRow();

        if (r > -1) {
            String id = table2.getModel().getValueAt(r, 0).toString();

            XmlFile.removeXml(filePath + File.separator + "file.xml", id);

            dmodel2.removeRow(r);
        }

        listApp = new ArrayList<Application>();
        listApp = XmlFile.readFileXml(filePath + File.separator + "file.xml");

        isRunning = true;


    }//GEN-LAST:event_btRemoveWebMouseClicked

    private void btEditWebMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btEditWebMouseClicked
        int r = table2.getSelectedRow();

        if (r > -1) {

            List<Application> list = XmlFile.readFileXml(filePath + File.separator + "file.xml");
            String id = table2.getModel().getValueAt(r, 0).toString();


            Application app = new Application();

            for (Application application : list) {

                if (application.getId().equals(id)) {

                    app = application;
                    System.out.println(app);
                    break;
                }
            }

//            String window = table1.getModel().getValueAt(r, 1).toString();
            AddBlockWindowDialog ad = new AddBlockWindowDialog(this, app, "2");
            ad.setVisible(true);
        }
    }//GEN-LAST:event_btEditWebMouseClicked

    private void jLabel26MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel26MouseClicked
//        RunBlockWindowDialog runBlockWindowDialog = new RunBlockWindowDialog(this);
//        runBlockWindowDialog.setVisible(true);
    }//GEN-LAST:event_jLabel26MouseClicked

    private void jTabbedPane1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTabbedPane1MouseClicked


        if (jTabbedPane1.getSelectedIndex() == 2) {
            searchAllTable3();
        } else if (jTabbedPane1.getSelectedIndex() == 3) {

            new Thread(new Runnable() {
                @Override
                public void run() {
                    searchAllTable4();
                }
            }).start();

            ShowHistoryDialog showHistoryDialog = new ShowHistoryDialog(this);
            showHistoryDialog.setVisible(true);


        }


    }//GEN-LAST:event_jTabbedPane1MouseClicked

    private void btRemoveBlockMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btRemoveBlockMouseClicked



        int[] selectedRows = table3.getSelectedRows();

        for (int i : selectedRows) {
            String id = table3.getValueAt(i, 0).toString();

            for (int j = 0; j < list3.size(); j++) {
                if (id.equals(list3.get(j).getId())) {
                    list3.remove(j);
                    break;
                }
            }


        }

        XmlFile3.removeXml(filePath + File.separator + "fileHistory.xml", list3);


        searchAllTable3();





    }//GEN-LAST:event_btRemoveBlockMouseClicked

    private void jLabel31MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel31MouseClicked

//        JFileChooser jf = new JFileChooser();
//        FileNameExtensionFilter filter = new FileNameExtensionFilter("TEXT FILES", "txt", "text");
//        jf.setFileFilter(filter);
//        System.out.println("paht");
//        JFileChooser fS = new JFileChooser();
//        fS.setAcceptAllFileFilterUsed(false);
//        fS.setMultiSelectionEnabled(false);
//        fS.setFileFilter(new FileNameExtensionFilter("Text File", ".class"));
//
//        fS.showSaveDialog(this);
//        fS.setFileFilter(new FileNameExtensionFilter(excelExtDesc, ".java"));


        // parent component of the dialog


        JFileChooser fileChooser = new JFileChooser();
        FileNameExtensionFilter filter = new FileNameExtensionFilter(".txt", "txt", "text");
        fileChooser.setFileFilter(filter);
        fileChooser.setDialogTitle("Specify a file to save");

        int userSelection = fileChooser.showSaveDialog(this);

        if (userSelection == JFileChooser.APPROVE_OPTION) {

            FileWriter fw = null;
            try {

                String path = "";

                List<ApplicationAccessed> list = XmlFile3.readFileXml(filePath + File.separator + "fileHistory.xml");


                File fileToSave = fileChooser.getSelectedFile();

                System.out.println("Save as file: " + fileToSave.getAbsolutePath());

                String name = fileToSave.getName();

                if (name.endsWith(".txt")) {
                    path = fileToSave.getAbsolutePath();
                } else {
                    String ext = fileChooser.getFileFilter().getDescription();
                    if (ext.equals(".txt")) {
                        path = fileToSave.getAbsolutePath() + ext;
                    }
                }

                File file = new File(path);

                // if file doesnt exists, then create it
                if (!file.exists()) {
                    file.createNewFile();
                }


                fw = new FileWriter(file.getAbsoluteFile());
                BufferedWriter bw = new BufferedWriter(fw);

                for (ApplicationAccessed applicationAccessed : list) {
                    String t = applicationAccessed.getDate() + "          "
                            + applicationAccessed.getHours() + "          "
                            + applicationAccessed.getUser() + "          "
                            + applicationAccessed.getWindow();
                    bw.write(t);
                    bw.newLine();
                }

                bw.close();
                System.out.println("Done");


            } catch (IOException ex) {
                ex.printStackTrace();
            } finally {
                try {
                    fw.close();
                } catch (IOException ex) {
                    ex.printStackTrace();
                }

            }



        }

    }//GEN-LAST:event_jLabel31MouseClicked

    private void jPanel4MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel4MouseClicked
    }//GEN-LAST:event_jPanel4MouseClicked

    private void btViewHistoryMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btViewHistoryMouseClicked

        ShowHistoryDialog showHistoryDialog = new ShowHistoryDialog(this);
        showHistoryDialog.setVisible(true);


    }//GEN-LAST:event_btViewHistoryMouseClicked

    private void jLabel36MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel36MouseClicked

        ShowHistoryDialog showHistoryDialog = new ShowHistoryDialog(this);
        showHistoryDialog.setVisible(true);

    }//GEN-LAST:event_jLabel36MouseClicked

    private void jLabel40MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel40MouseClicked

        JFileChooser fileChooser = new JFileChooser();
        FileNameExtensionFilter filter = new FileNameExtensionFilter(".txt", "txt", "text");
        fileChooser.setFileFilter(filter);
        fileChooser.setDialogTitle("Specify a file to save");

        int userSelection = fileChooser.showSaveDialog(this);

        if (userSelection == JFileChooser.APPROVE_OPTION) {

            FileWriter fw = null;
            try {

                String path = "";

                List<ApplicationAccessed> list = XmlFile3.readFileXml(filePath + File.separator + "fileHistory.xml");


                File fileToSave = fileChooser.getSelectedFile();

                System.out.println("Save as file: " + fileToSave.getAbsolutePath());

                String name = fileToSave.getName();

                if (name.endsWith(".txt")) {
                    path = fileToSave.getAbsolutePath();
                } else {
                    String ext = fileChooser.getFileFilter().getDescription();
                    if (ext.equals(".txt")) {
                        path = fileToSave.getAbsolutePath() + ext;
                    }
                }

                File file = new File(path);

                // if file doesnt exists, then create it
                if (!file.exists()) {
                    file.createNewFile();
                }


                fw = new FileWriter(file.getAbsoluteFile());
                BufferedWriter bw = new BufferedWriter(fw);

                for (ApplicationAccessed applicationAccessed : list) {
                    String t = applicationAccessed.getDate() + "          "
                            + applicationAccessed.getHours() + "          "
                            + applicationAccessed.getUser() + "          "
                            + applicationAccessed.getWindow();
                    bw.write(t);
                    bw.newLine();
                }

                bw.close();
                System.out.println("Done");


            } catch (IOException ex) {
                ex.printStackTrace();
            } finally {
                try {
                    fw.close();
                } catch (IOException ex) {
                    ex.printStackTrace();
                }

            }



        }

    }//GEN-LAST:event_jLabel40MouseClicked

    private void jLabel39MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel39MouseClicked


        int[] selectedRows = table4.getSelectedRows();

        for (int i : selectedRows) {
            String id = table4.getValueAt(i, 0).toString();

            for (int j = 0; j < list4.size(); j++) {
                if (id.equals(list4.get(j).getId())) {
                    list4.remove(j);
                    break;
                }
            }

        }

        XmlFile3.removeXml(filePath + File.separator + "fileHistory.xml", list4);

        searchAllTable4();




    }//GEN-LAST:event_jLabel39MouseClicked

    private void jPanel3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jPanel3MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_jPanel3MouseClicked

    private void btCreatePassMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_btCreatePassMouseClicked
        CreateAcountDialog createAcountDialog = new CreateAcountDialog(this);
        createAcountDialog.setVisible(true);
    }//GEN-LAST:event_btCreatePassMouseClicked

    private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton2ActionPerformed
//        System.out.println("phat");
        langPo = false;
        ReadWriteFile.write(filePath + File.separator + "lang.phat", "en");
        initLanguage(filePath + File.separator + "lange_en.properties");
        setTextAll();


    }//GEN-LAST:event_jRadioButton2ActionPerformed

    private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jRadioButton1ActionPerformed
        langPo = true;
        ReadWriteFile.write(filePath + File.separator + "lang.phat", "po");
        initLanguage(filePath + File.separator + "lange.properties");
        setTextAll();


    }//GEN-LAST:event_jRadioButton1ActionPerformed

    private void setTextAll() {
        btCreatePass.setText(BtCreatePass);
        //tab1
        cbStartWithWindow.setText(CbStartWithWindow);
        jPanel5.setBorder(BorderFactory.createTitledBorder(BorderFactory.createTitledBorder(null, BorderTextTab1, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 0, 12))));
        btAddApp.setText(BtAddApp);
        btEditApp.setText(BtEditApp);
        btRemoveApp.setText(BtRemoveApp);
        jTabbedPane1.setTitleAt(0, HeaderTab1);
        //tab2
        cbBlockWeb.setText(CbBlockWeb);
        jPanel8.setBorder(BorderFactory.createTitledBorder(BorderFactory.createTitledBorder(null, BorderTextTab2, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 0, 12))));
        btAddSite.setText(BtAddSite);
        btEditWeb.setText(BtEditWeb);
        btRemoveWeb.setText(BtRemoveWeb);
        jTabbedPane1.setTitleAt(1, HeaderTab2);
        //tab3
        jPanel10.setBorder(BorderFactory.createTitledBorder(BorderFactory.createTitledBorder(null, BorderTextTab3, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 0, 12))));
        btViewHistory.setText(BtViewHistory);
        jLabel31.setText(JLabel31);
        btRemoveBlock.setText(BtRemoveBlock);
        jTabbedPane1.setTitleAt(2, HeaderTab3);
        //tab4
        jPanel12.setBorder(BorderFactory.createTitledBorder(BorderFactory.createTitledBorder(null, BorderTextTab4, TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Tahoma", 0, 12))));
        jLabel36.setText(BtViewHistory);
        jLabel40.setText(JLabel31);
        jLabel39.setText(BtRemoveBlock);
        jTabbedPane1.setTitleAt(3, HeaderTab4);
        //table
        setTextHeaderTable();

    }

    private void setTextHeaderTable() {

        JTableHeader th1 = table1.getTableHeader();
        th1.getColumnModel().getColumn(1).setHeaderValue(Window);
        th1.getColumnModel().getColumn(2).setHeaderValue(User);
        th1.getColumnModel().getColumn(3).setHeaderValue(Start);
        th1.getColumnModel().getColumn(4).setHeaderValue(End);
        th1.repaint();

        JTableHeader th2 = table2.getTableHeader();
        th2.getColumnModel().getColumn(1).setHeaderValue(Web);
        th2.getColumnModel().getColumn(2).setHeaderValue(User);
        th2.getColumnModel().getColumn(3).setHeaderValue(Start);
        th2.getColumnModel().getColumn(4).setHeaderValue(End);
        th2.repaint();

        JTableHeader th3 = table3.getTableHeader();
        th3.getColumnModel().getColumn(1).setHeaderValue(Window);
        th3.getColumnModel().getColumn(2).setHeaderValue(User);
        th3.getColumnModel().getColumn(3).setHeaderValue(Date);
        th3.getColumnModel().getColumn(4).setHeaderValue(Time);
        th3.repaint();

        JTableHeader th4 = table4.getTableHeader();
        th4.getColumnModel().getColumn(1).setHeaderValue(Window);
        th4.getColumnModel().getColumn(2).setHeaderValue(User);
        th4.getColumnModel().getColumn(3).setHeaderValue(Date);
        th4.getColumnModel().getColumn(4).setHeaderValue(Time);
        th4.repaint();




    }
    /**
     * @param args the command line arguments
     */
//    public static void main(String args[]) {
//        /* Set the Nimbus look and feel */
//        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
//        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
//         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
//         */
//        try {
//            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        //</editor-fold>
//
//        /* Create and display the form */
//        java.awt.EventQueue.invokeLater(new Runnable() {
//            public void run() {
//                Demo demo = new Demo();
//                demo.setLocationRelativeTo(null);
//                demo.setVisible(true);
//            }
//        });
//    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel btAddApp;
    private javax.swing.JLabel btAddSite;
    public javax.swing.JLabel btCreatePass;
    private javax.swing.JLabel btEditApp;
    private javax.swing.JLabel btEditWeb;
    private javax.swing.JLabel btRemoveApp;
    private javax.swing.JLabel btRemoveBlock;
    private javax.swing.JLabel btRemoveWeb;
    private javax.swing.JLabel btViewHistory;
    private javax.swing.ButtonGroup buttonGroup1;
    public javax.swing.JCheckBox cbBlockWeb;
    private javax.swing.JCheckBox cbStartWithWindow;
    private javax.swing.JCheckBox jCheckBox2;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel30;
    private javax.swing.JLabel jLabel31;
    private javax.swing.JLabel jLabel33;
    private javax.swing.JLabel jLabel34;
    private javax.swing.JLabel jLabel36;
    private javax.swing.JLabel jLabel37;
    private javax.swing.JLabel jLabel38;
    private javax.swing.JLabel jLabel39;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel40;
    private javax.swing.JLabel jLabel41;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel10;
    private javax.swing.JPanel jPanel12;
    private javax.swing.JPanel jPanel13;
    private javax.swing.JPanel jPanel14;
    private javax.swing.JPanel jPanel15;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JRadioButton jRadioButton1;
    private javax.swing.JRadioButton jRadioButton2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTable table1;
    private javax.swing.JTable table2;
    private javax.swing.JTable table3;
    private javax.swing.JTable table4;
    // End of variables declaration//GEN-END:variables
}
